import os
import queue
import sys
import threading
import requests
import redis
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# 设置标准输出为无缓冲
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', buffering=1)  # 行缓冲
DEBGUG = False 
DEBGUG = True # 本地环境
#是否把数据推送到数据库
IS_PUSH_DB=True
#IS_PUSH_DB=False # 本地环境
if DEBGUG:
    Q = queue.Queue()
    R = redis.Redis(host='127.0.0.1', port=6379, db=3)
else:
    Q = queue.Queue()
    R = redis.Redis(host='localhost', port=6379, db=3)
# 测试redis是否连接成功
try:
    R.ping()
    print(f"Redis 连接成功!")
except redis.ConnectionError:
    print(f"Redis 连接失败，请检查服务器是否启动")

#远程推送地址
if DEBGUG:
    REMOTE_DB_PUSH_URL =[
        "https://xf-162-test.lottefuture.com/backend/doubanpushnew",
        #"https://xf-162.lottefuture.com/backend/doubanpushnew",

    ]
else:
    REMOTE_DB_PUSH_URL =[
        "https://xf-162-test.lottefuture.com/backend/doubanpushnew",
        "https://xf-162.lottefuture.com/backend/doubanpushnew",
    ]
#解析产品的接口
PARSE_PRODUCT="http://cgi-bin.lottefuture.com/python/link-parse.php"



# 隧道域名:端口号
#tunnel = "u705.kdltps.com:15818"
tunnel = "tun-festhu.qg.net:17690"

# 用户名密码方式
#username = "t14920023015118"
#password = "lny2ogcg"
username = "E5F6D6EE"
password = "9B219197EE72"

#print(proxy_url)
PROXIES = {
    "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel},
    "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": tunnel}
}


DOMAIN_NAME="https://news.xianbao.fun"
if  DEBGUG:
    COOKIE_PATH = r"./douban_cookies.json"
else:
    COOKIE_PATH = r"./douban_cookies.json"

